RENUMBERING


SRename can perform intelligent renumbering of filename sequences in one go. It is not limited in the formats it can support, as it scans the filenames for numbers of up to 9 digits long, which can have leading zeros, and can be in
any position in the filename, or on their own.
You don't have to specify the order of renaming, normal or reverse, as with other renumbering utilities because it scans the filenames in the directory and decides which way to go.
Furthermore you don't have to worry for filename clashes during renumbering, as any clashes will be found before the actual renaming begins, and the clashing filenames will be given temporary names before are finally renamed.
Inverting the numbers in a sequence can also be performed, a feature that would be useful in compiling ping-pong animations.

The following commands are used in renumbering:

Renumbering actions: (all can be given at once)

RENUMBER
STEP
PLACES
INVERT
NUMBERPOS

Renumbering selectors:

BASENAME

Renumbering options:

UPTO
PRESERVECASE

 



Actions:


RENUMBER (RN) <new starting number> :


Specifies the new starting number of a filename sequence. All matching filenames will be renumbered unless an ending number is specified with UPTO.

Examples:

> SRename Data:picture001 RN 50 : will renumber all filenames that begin with "picture" and have a number attached at the end, to values starting with 50. The leading zeros will be preserved.

output:

"picture001" renamed as "picture050"
"picture002" renamed as "picture051"
"picture003" renamed as "picture052"
"picture004" renamed as "picture053"
"picture005" renamed as "picture054"
   ....

> SRename Data:picture001 RN 50 UT 4 : as above but will renumber up to filename "picture004".

output:

"picture001" renamed as "picture050"
"picture002" renamed as "picture051"
"picture003" renamed as "picture052"
"picture004" renamed as "picture053"

> SRename Data:10.frame RN 020 : will renumber all filenames that end in ".frame" and are preceded with a value of 10 or greater, to values starting with 020.

output:

"10.frame" renamed as "020.frame"
"11.frame" renamed as "021.frame"
"12.frame" renamed as "022.frame"
"13.frame" renamed as "023.frame"
"14.frame" renamed as "024.frame"
   ....

Note that when you supply a new starting number with leading zeros, the old number format is overridden.



STEP (ST) <step value> :



Defines the increment value of renumbering. The default increment is 1. It can also take negative values.

Examples:
> SRename Data:picture001 RN 30 ST 2 : increases the new starting value by 2.

output:

"picture001" renamed as "picture030"
"picture002" renamed as "picture032"
"picture003" renamed as "picture034"
"picture004" renamed as "picture036"
  ....

> SRename Data:picture001 ST 3 : will keep the original starting value but will increase the destination numbers in steps of 3 :

output:

"picture004" renamed as "picture010"
"picture003" renamed as "picture007"
"picture002" renamed as "picture004"
"picture001" not changed
  ....

Note that the renumbering is executed in reverse order to avoid a clash when renaming "picture002" to "picture004" ("picture004" already exists).



PLACES (PL) <places value> :



Sets the number format of the destination filenames. This affects the number of leading zeros the numbers will have.
If you specify a places value that is smaller than the digits a number already has that number will be unaffected. Any numbers will less digits than the places value will be padded with leading zeros.

Examples:

> SRename Data:picture001 RN 30 PL 4 : makes the numbers 4-digit.

output:

"picture001" renamed as "picture0030"
"picture002" renamed as "picture0031"
"picture003" renamed as "picture0032"
"picture004" renamed as "picture0033"
  ....

> SRename Data:picture001 PL 1 : strips all leading zeros from the numbers.

output:

"picture001" renamed as "picture1"
"picture002" renamed as "picture2"
"picture003" renamed as "picture3"
"picture004" renamed as "picture4"
  ....

> SRename Data:picture001 UT 3 PL 2 : will renumber from number 001 to 003, and make the numbers 2-digit.

output:

"picture001" renamed as "picture01"
"picture002" renamed as "picture02"
"picture003" renamed as "picture03"



INVERT (IV) :



Invert the numbers in a filename sequence. This is exactly how inverting works:

 

Original filename   New filename
file.10 becomes file.14
file.11 becomes file.13
file.12 not changed file.12
file.13 becomes file.11
file.14 becomes file.10



You may have noticed that executing this sequence of rename commands has a problem: how can "file.10" become "file.14" when "file.14" already exists. SRename sees that and when destination filenames already exist, the files to be renumbered are given temporary filenames until the existing filenames themselves have been renumbered, so after this is done the temporary filenames are given their normal destination filenames.
A non-resolvable error occurs ("New number already exists" error) if these existing filenames that cause clashes are not scheduled to be renumbered because they are outside the range of files to be renumbered.

Examples:

> SRename Data:file100 IV : inverts the whole filename sequence.

output:

"file100" renamed as "109.srtemp861A5BC"
"file101" renamed as "108.srtemp861A5BC"
"file102" renamed as "107.srtemp861A5BC"
"file103" renamed as "106.srtemp861A5BC"
"file104" renamed as "105.srtemp861A5BC"
"file105" renamed as "file104"
"file106" renamed as "file103"
"file107" renamed as "file102"
"file108" renamed as "file101"
"file109" renamed as "file100"
"109.srtemp861A5BC" renamed as "file109"
"108.srtemp861A5BC" renamed as "file108"
"107.srtemp861A5BC" renamed as "file107"
"106.srtemp861A5BC" renamed as "file106"
"105.srtemp861A5BC" renamed as "file105"

Notice how numbers 100 to 104 are given temporary filenames before been finally renumbered, because of clashes that would occur during the renaming process.

> SRename Data:file100 RN 50 IV : inverts the filename sequence and gives it a starting number of 50.

output:

"file100" renamed as "file59"
"file101" renamed as "file58"
"file102" renamed as "file57"
"file103" renamed as "file56"
"file104" renamed as "file55"
"file105" renamed as "file54"
"file106" renamed as "file53"
"file107" renamed as "file52"
"file108" renamed as "file51"
"file109" renamed as "file50"



NUMBERPOS (NP) <position value> :



Sets the position of the number within the basename. Positive position values means character position from the left and negative values means character position from the right.

Examples:

> SRename frame100.iff NP 1 : will move all numbers in the filename sequence at the first character of the basename.

output:

"frame100.iff" renamed as "100frame.iff"
"frame101.iff" renamed as "101frame.iff"
"frame102.iff" renamed as "102frame.iff"
"frame103.iff" renamed as "103frame.iff"
  ....

> SRename 100frame.iff NP -5 : all numbers will be moved at the 5th character of the basename from the end.

output:

"100frame.iff" renamed as "frame100.iff"
"101frame.iff" renamed as "frame101.iff"
"102frame.iff" renamed as "frame102.iff"
"103frame.iff" renamed as "frame103.iff"
  ....

 



Selectors:


BASENAME (BN) :



Selects the basename of a sequence for modification. Every available action can be applied to the basename with the exception of CONV8+3 action which wouldn't be very useful if applied to a basename because the complete filenames would exceed 11 characters as the numbers would also be included.

After the basename has been modified the position of the number within the basename is calculated automatically according to the characters that have been inserted to or deleted from it, unless the number position is set manually with the NUMBERPOS action.
if the basename has components (prefix-main-suffix) and these are reorganised with SWAP, RSHIFT or LSHIFT, then the number follows the component in which it is contained to it's new position.
BASENAME differs from other selectors because if multiple actions are to be given to modify the basename, it doesn't have to be given repeatedly before each action.

Examples:

> SRename file100 BN TO picture : replaces the existing basename with "picture" in every filename.
output:

"file100" renamed as "picture100"
"file101" renamed as "picture101"
"file102" renamed as "picture102"
"file103" renamed as "picture103"
  ....

> SRename file100 BN DL : deletes the basename.
output:

"file100" renamed as "100"
"file101" renamed as "101"
"file102" renamed as "102"
"file103" renamed as "103"
  ....

> SRename Frame001.iff BN SW : swaps the basename components.
output:

"Frame001.iff" renamed as "iff.Frame001"
"Frame002.iff" renamed as "iff.Frame002"
"Frame003.iff" renamed as "iff.Frame003"
"Frame004.iff" renamed as "iff.Frame004"
  ....

> SRename Frame001.iff BN MA LW MA R 1 UP : makes the main component of the basename lowercase and then it's last character uppercase. As was stated above BASENAME only has to be given once even for multiple actions.
output:

"Frame001.iff" renamed as "framE001.iff"
"Frame002.iff" renamed as "framE002.iff"
"Frame003.iff" renamed as "framE003.iff"
"Frame004.iff" renamed as "framE004.iff"
  ....

 



Options:



UPTO (UT) <number or filename> :


Specifies the filename up to which the given renumbering actions will be performed. It can either accept the number of the ending filename or the ending filename itself so that if SRename is used from a file manager like Directory Opus you don't have to enter the ending number with the keyboard but you can select the starting and ending filenames from the lister instead.
It doesn't matter if the filename given to UPTO contains a path or not. If you give this option you must also give at least one renumber action with it otherwise a "Required argument missing" error will occur.

Examples:

> SRename Data:picture001 RN 50 UT 6 : will renumber from "picture001" up to "picture006".

> SRename Data:frame100 UT frame110 BN TO AnimFrame : will change the basename from "frame100" up to "frame110".



PRESERVECASE (PC) :



This option preserves each basename's casing. If PRESERVECASE is not given all basenames will be the same as the basename of the first filename in the sequence, which is the default behaviour.

Example:

> SRename frame01 RN 20 PC

output:

"frame01" renamed as "frame20"
"FRAME02" renamed as "FRAME21"
"frame03" renamed as "frame22"
"FRAME04" renamed as "FRAME23"
"frame05" renamed as "frame24"

As you see the second and fourth basename remain in upper case.